<template>
    <div>
        <h1>显示</h1>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>Id</td>
                    <td>姓名</td>
                    <td>手机号</td>
                    <td>积分</td>
                    <td>余额</td>
                    <td>操作</td>
                </tr>

                <tr v-for="itme in data.list":key="itme.Id">
                    <td>{{ itme.Id }}</td>
                    <td>{{ itme.Name }}</td>
                    <td>{{ itme.Phone }}</td>
                    <td>{{ itme.JIfen }}</td>
                    <td>{{ itme.Money }}</td>
                    <td><input type="button" value="移除" @click="del(itme.Id)"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref,reactive, onMounted} from 'vue'
import axios from 'axios';
import { useRoute,useRouter } from 'vue-router';
const router=useRouter();
let data:any=reactive({
    list:[]
})
onMounted(()=>{
    getlist();
})
const getlist=()=>{
    axios({
        url:'/api/HY/GetShow',
        method:'get',
    })
    .then((res)=>{
        console.log(res);
        data.list=res.data;
    })
    .catch((err)=>{
        console.log(err);
        
    })
}
//-----------
const del=(id:any)=>{
    
    axios({
        url:'/api/HY/del',
        method:'delete',
        params:{id:id}
    })
    .then((res)=>{
        console.log(res);
   
    if(res.data>0)
    {
        alert("移除成功");
        return;
    }
    else
    {
        alert("移除失败");
        return;
    }
    })
    .catch((err)=>{
        console.log(err);
        
    })

}
</script>

<style scoped>

</style>